<template>
  <div class="cartWraper" :style="{ backgroundColor: bgc }" v-for="item of note" :key="item.id">
    <el-container>
      <el-header height="10px">
        <el-row>
          <el-col :span="18" class="headerTime">
            {{ date(item.moment) }}
          </el-col>
          <el-col :span="6" class="headerRight">
            {{ lb[item.label] }}
          </el-col>
        </el-row>
      </el-header>
      <el-main @click="upCPopupsShow(item, item.id)">
        <p>
          {{ item.message }}
        </p>
      </el-main>
      <el-footer height="10px">
        <el-row>
          <el-col :span="15" class="footLeft">
            <div class="like">
              <span class="iconfont icon-xiai"></span><i>
                {{ item.like }}
              </i>
            </div>
            <div class="liuyan">
              <span class="iconfont icon-liuyan"></span><i>
                {{ item.revoke }}
              </i>
            </div>
          </el-col>
          <el-col :span="9" class="footRight">{{ item.name }}</el-col>
        </el-row>
      </el-footer>
    </el-container>
  </div>
</template>

<script setup lang="ts">
import { ref, computed } from 'vue'
import { lable } from '../assets/data/wall'
import { date } from '../utils/tool/index'

import { storeToRefs } from 'pinia';
import { useMainStore } from '../store';

const mainStore = useMainStore()
let { cardData } = storeToRefs(mainStore)
const { upDetailPopups } = mainStore

const { bgc, note } = defineProps(['bgc', 'note'])

const lb = lable[1]

// 控制弹出层的显示
const upCPopupsShow = (data: any, id: number): void => {
  cardData.value = data
  upDetailPopups()
}

</script>

<style lang="scss" scoped>
$padLeft: 10px;
$wraperW: 260px;
$wraperH: 227px;

.cartWraper {
  height: $wraperH;
  width: $wraperW;
  border-radius: 5px;
  padding: $padLeft;
  box-sizing: border-box;
  position: relative;
  margin-top: 16px;
  border: 1px solid orange;
  cursor: pointer;

  &:hover {
    border: 1px solid rgb(255, 255, 255);
  }

  .el-header {
    padding: 0;
    margin: 0;
    margin-bottom: 15px;

    .headerTime {
      font-size: 12px;
      color: rgb(83, 83, 83);
    }

    .headerRight {
      font-size: 14px;
      color: rgb(83, 83, 83);
      text-align: center;
    }
  }

  .el-main {
    padding: 0;
    width: 100%;
    height: calc($wraperH - 70px);
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 8;
    overflow: hidden;
    font-size: 14px;
    box-sizing: border-box;
    padding: 0 10px;

    p {
      font-size: 18px;
      font-family: '楷体';
    }
  }

  .el-footer {
    width: 100%;
    padding: 0;
    position: absolute;
    bottom: 20px;
    left: $padLeft;

    .footLeft {
      font-size: 14px;

      div {
        display: inline;
        cursor: pointer;
      }

      &>div:first-of-type {
        margin-right: 10px;
      }

      .iconfont {
        color: rgb(72, 72, 72);
      }

      .icon-xiai:hover {
        color: red;
      }
    }

    .footRight {
      font-size: 14px;
      color: black;
      text-align: center;
    }
  }
}
</style>